<?php
class Resource_Doctrine extends Zend_Application_Resource_ResourceAbstract
{
    public function init()
    {
        try {
            $dbAdapter = $this->getBootstrap()->getResource('Db');
            $manager = Doctrine_Manager::getInstance();
            $conn = Doctrine_Manager::connection($dbAdapter->getConnection());
            $manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
            $manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
            $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
            $manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS);
            $manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_RECORDS); // revert
        } catch (Zend_Db_Adapter_Exception $e){
            echo $e->getMessage();
            require_once PUBLIC_PATH . 'install.php';
            exit;
        }
    }
}
